package com.xmg.boot.demo.bootlesson1.user.entity.es;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * @Author: ma
 * @CreateTime: 2023-11-28
 * @Description: ES实体类
 * @Version: 1.0
 */

//indexName: 索引  shards:分片数量  replicas：副本数量
@Data
@Document(indexName = "userdb",shards = 3,replicas = 1)
@NoArgsConstructor
@AllArgsConstructor
public class Book {
    @Id
    private String id;
    @Field(type= FieldType.Text,analyzer = "ik_max_word")
    private String title;
    @Field(type= FieldType.Keyword)
    private String images;
    @Field(type=FieldType.Float)
    private float price;
    @Field(type = FieldType.Date, format = DateFormat.custom,pattern ="yyyy-MM-dd HH:mm:ss")
    //@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    //@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date actiontime;

}
